<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>Shop活动编辑</title>
        <script type="text/javascript" src="../../inc/ctx.jsp"></script>
        <script type="text/javascript" src="../js/g.js"></script>
        <script type="text/javascript" src="../js/shoptype.js"></script>
        <script type="text/javascript" src="http://cdn.uuola.cn/js/address.js" charset="utf-8"></script>
        <script type="text/javascript" src="http://cdn.uuola.cn/js/formvalid.js" charset="utf-8"></script>
        <link rel="stylesheet" href="../../ked/js/themes/default/default.css" />
        <link rel="stylesheet" href="../../ked/js/plugins/code/prettify.css" />
        <script charset="utf-8" src="../../ked/js/kindeditor-min.js"></script>
        <script charset="utf-8" src="../../ked/js/zh_CN.js"></script>
        <script charset="utf-8" src="../../ked/js/plugins/code/prettify.js"></script>
        <script type="text/javascript" src="../js/channeltype.js"></script>
        <link href="../css/com.css" type="text/css" rel="stylesheet"/>
        <style>
            img.s1{width:100px;border:1px #EFEFEF solid;padding:1px;}
            #panel{width:950px;}
            #panel table{width:940px;}
            span.s1{color:#B1B1B1;}
            #submitBtn{width:150px;height:35px;}
        </style>
    </head>
    <body>

        <div id="panel">
            <form id="editFrm" name="editFrm">
                <input type="hidden" value="" name="shopid" id="shopid" />
                <table>
                    <tr>
                        <th colspan="3">编辑Shop信息</th>
                    </tr>
                    <tr>
                        <td class="r">所属板块：</td>
                        <td><span id="channeltype"></span></td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td width="180" height="27" class="r">商铺名称：</td>
                        <td width="49%">
                            <input name="shopname" type="text" id="shopname" tabindex="1" size="50" maxlength="32" valid="required" errmsg="商铺名称不能为空!" />* 
                        </td>
                        <td width="34%"><div id="err_shopname"><span class="s1">商铺名称.32个字符内.勿使用特殊字符.</span></div></td>
                    </tr>
                    <tr>
                        <td class="r">摘要/概要：</td>
                        <td colspan="2"><label for="summary"></label>
                            <textarea name="summary" id="summary" cols="55" rows="4" tabindex="3"></textarea></td>
                    </tr>
                    <tr>
                        <td class="r">qq：</td>
                        <td><input name="qq" type="text" id="qq" tabindex="7" maxlength="16"></td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td class="r">tbnick：</td>
                        <td><input name="tbnick" type="text" id="tbnick" tabindex="7" maxlength="32"></td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td class="r">email：</td>
                        <td><input name="email" type="text" id="email" tabindex="7" maxlength="64"></td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td class="r">地区：</td>
                        <td>
<select name="province" id="province" class="s1" style="width:110px;"></select>
<select name="city" id="city" class="s1" style="width:110px;"></select>
<select name="district" id="district" class="s1" style="width:110px;"></select>
<input name="local" type="hidden" id="local" tabindex="7" maxlength="32"></td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td class="r">shop类型：</td>
                        <td><script>out_shoptype();</script></td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td class="r">信息主图：</td>
                        <td><label for="pic"></label>
                            <input name="pic" type="text" id="pic" size="50">
                            <input type="button" name="uploadBtn" id="uploadBtn" value="上传图片" tabindex="5" onclick="TxBox.upload('pic', '-ms-ss-', '');">
                        </td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td class="r">跳转地址：</td>
                        <td><label for="url"></label>
                            <input name="url" type="text" id="url" size="50">
                        </td>
                        <td>&nbsp;<span class="s1">跳转地址以http://开头</span></td>
                    </tr>
                    <tr>
                        <td class="r">信息内容：</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td class="r" colspan="3">
                            <textarea name="content" id="content" cols="150" rows="20"></textarea></td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td></td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td class="r">&nbsp;</td>
                        <td class="c"><input name="submitBtn" type="button" class="button medium orange" id="submitBtn" tabindex="7" value="保存信息" onClick="Shop.submit();" /></td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td class="c"></td>
                        <td>&nbsp;</td>
                    </tr>
                </table>
            </form>
        </div>



        <script type="text/javascript">
            var id = ut.get('id');
            var frm = ut.e('editFrm');
            initValid(frm);
            
            function initFormData(){
                $('#channeltype').text(getChannelType('1'));
                if(va.isnull(id)){
                    ut.m('信息ID参数错误');
                    return;
                }
                var p={'shopid':id,'t':ut.r()};
                $.get('../app/hotshop/query_shop_edit.shtm',$.param(p),function(x){
                    if(typeof x == 'string'){
                        ut.m('初始化表单错误.'+x);
                        return;
                    }
                    $('#shopid').val(x.shopid);
                    $('#channeltype').text(getChannelType(x.channeltype));
                    $('#shopname').val(x.shopname);
                    $('#summary').val(x.summary);
                    $('#qq').val(x.qq);
                    $('#shoptype').val(x.shoptype);
                    $('#qq').val(x.qq);
                    $('#pic').val(x.pic);
                    $('#tbnick').val(x.tbnick);
                    $('#url').val(x.url);
                    $('#email').val(x.email);
                    $('#local').val(x.local);
                    var loc = x.local.split(' ');
                    addressInit('province', 'city', 'district', loc[0], loc[1], loc[2]);
                    //contentEditor.html(x.content);
                });
            };
            
            // 初始化编辑器
            var contentEditor ; 
            KindEditor.ready(function(K) {
                contentEditor = K.create('#content', {
                    uploadJson : KindUpload.UploadUrl,
                    fileManagerJson : KindUpload.fileMgrUrl,
                    allowFileManager : true,
                    afterCreate : function() {
                        var self = this;
                        self.sync();
                    }
                });
                prettyPrint();
                initFormData();
            });
            
            var Shop ={
                submit:function(){
                    contentEditor.sync();
                    if(validator(frm)){
                    var area = [$('#province').val(),$('#city').val(),$('#district').val()].join(' ');
                    $('#local').val(area.indexOf('-')<0?area:'-');
                        $.post('../app/hotshop/update.shtm',ut.getFormData('#editFrm'),function(x){
                            if($.trim(x)=='ok'){
                                ut.m('更新成功!');
                                win.close();
                            }else{
                                ut.m('更新失败. '+x);
                            }   
                        });
                    }
                }
            };     


        </script>
    </body>
</html>
